﻿using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using TeamsPortal.Configuration;
using TeamsPortal.Configuration.Routing;
using TeamsPortal.Web.Extensions;
using System.Web.Http;
using TeamsPortal.Web.Output2.App_Start;

namespace TeamsPortal.Web.Output2
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : HttpApplication//NinjectHttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            //Routes are registered using: TeamsPortal.Web.Extensions.RoutingHelper
            //Routes are configured at: Config\Routes.config
            RoutingHelper.RegisterRoutes(routes, RouteMappingConfiguration.Current);
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            //Inject as a dependency
            SiteConfiguration.Current.PathResolver = Server.MapPath;
        }

    }
}